//
//  FindPasswordViewController.m
//  DaiShengInvest
//
//  Created by davinci on 17/6/8.
//  Copyright © 2017年 davinci. All rights reserved.
//

#import "FindPasswordViewController.h"
#import "ResetPasswordViewController.h"

@interface FindPasswordViewController ()

@property (nonatomic, weak)UIImageView * backViewImage;

@property (nonatomic, weak)UIView * backViewOne;

@property (nonatomic, weak)UILabel * telLabel;

@property (nonatomic, weak)UITextField * telTextField;

@property (nonatomic, weak)UIButton * sentMessageButton;

@end

@implementation FindPasswordViewController


//显示导航栏
-(void)viewWillAppear:(BOOL)animated{
    
    self.navigationController.navigationBarHidden = NO;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    [self setupNavBar];
    
    [self setupUI];

}

- (void)setupNavBar{
    
    self.title = @"找回密码";
    
    UIButton * backButton = [[UIButton alloc] init];
    
    backButton.frame = CGRectMake(15 * SCREENH6, 5 * SCREENH6, 12 * SCREENH6, 20 * SCREENH6);
    [backButton setImage:[UIImage imageNamed:@"1返回"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backToLogView) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem * leftButton = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    
    self.navigationItem.leftBarButtonItem = leftButton;
}


- (void)setupUI{
    
    UIImageView * backImage = [[UIImageView alloc] init];
    
    backImage.image = [UIImage imageNamed:@"背景"];
    
    self.backViewImage = backImage;
    
    [self.view addSubview:self.backViewImage];
    
    
    UIView * backViewOne = [[UIView alloc] init];
    
    backViewOne.backgroundColor = [UIColor whiteColor];
    backViewOne.alpha = 0.1;
    
    self.backViewOne = backViewOne;
    
    [self.view addSubview:self.backViewOne];
    
    UILabel * telLabel = [[UILabel alloc] init];
    
    telLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15 * SCREENH6];
    telLabel.textColor = [UIColor whiteColor];//ColorWithRGB(0xeeeeee);
    telLabel.text = @"手机号";
    
    self.telLabel = telLabel;
    
    [self.view addSubview:self.telLabel];
    
    UITextField * telText = [[UITextField alloc] init];
    
    telText.borderStyle = UITextBorderStyleNone;
    telText.backgroundColor = [UIColor clearColor];
    
    //设置光标颜色
    telText.tintColor = ColorWithRGB(0x808486);
    //修改占位符文字颜色
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSForegroundColorAttributeName] = ColorWithRGB(0x808486);
    attrs[NSFontAttributeName] = [UIFont fontWithName:@"PingFangSC-Regular" size:15 * SCREENH6];
    telText.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入手机号" attributes:attrs];
    telText.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15 * SCREENH6];
    telText.textColor = ColorWithRGB(0x808486);
    
    self.telTextField = telText;
    
    [self.view addSubview:self.telTextField];
    
    
    UIButton * sentMessageButton = [[UIButton alloc] init];
    
    [sentMessageButton setTitle:@"发送验证码" forState:UIControlStateNormal];
    sentMessageButton.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:15 * SCREENH6];//[UIFont systemFontOfSize:15];
    [sentMessageButton setBackgroundColor:ColorWithRGB(0xa92c44)];
    sentMessageButton.layer.borderColor = [[UIColor blackColor] CGColor];
    //边框宽度
    sentMessageButton.layer.borderWidth =1.0f;
    //处理圆角
    sentMessageButton.layer.cornerRadius =5.0f;
    [sentMessageButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [sentMessageButton addTarget:self action:@selector(pushToResetPassword) forControlEvents:UIControlEventTouchUpInside];
    
    self.sentMessageButton = sentMessageButton;
    
    [self.view addSubview:self.sentMessageButton];
    
}


- (void)viewDidLayoutSubviews{
    
    [self.backViewImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.top.bottom.mas_equalTo(self.view);
    }];
    
    [self.backViewOne mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.width.mas_equalTo(345 * SCREENH6);
        make.height.mas_equalTo(55 * SCREENH6);
        make.top.mas_equalTo(self.view).offset(90 * SCREENH6);
    }];
    
    [self.telLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.backViewOne).offset(9 * SCREENH6);
        make.centerY.mas_equalTo(self.backViewOne);
        make.width.mas_equalTo(45 * SCREENH6);
    }];
    
    [self.telTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.backViewOne);
        make.leading.mas_equalTo(self.telLabel.mas_trailing).offset(42 * SCREENH6);
        make.height.mas_equalTo(self.telLabel);
        make.width.mas_equalTo(125 * SCREENH6);
    }];

    [self.sentMessageButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.backViewOne.mas_bottom).offset(44 * SCREENH6);
        make.width.leading.trailing.mas_equalTo(self.backViewOne);
        make.height.mas_equalTo(46 * SCREENH6);
    }];
    
    
}



- (void)pushToResetPassword{
    
    ResetPasswordViewController * resetPassword = [ResetPasswordViewController new];
        
    [self.navigationController pushViewController:resetPassword animated:YES];
}


- (void)backToLogView{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
